#!/bin/sh
# auf strut.io editieren, Präsentieren, Publishen, Strg-S zum Saven, dann das regex Script drüber laufen lassen.

Title="SecuLution"
Description="SecuLution product presentation"
Author="SecuLution GmbH"
page=home_en
page_files="$page"_files
filename=$page.htm
backup=$filename.bak
tmpfilename=$filename.tmp
home="home_en.htm"

if grep -q '<!-- processed -->' $filename; then
	if test -e $backup; then
		echo $0 using backup $backup
		cp $backup $filename
	else
		echo Backup $backup existiert nicht
		exit 1
	fi
else
	echo Creating Backup $backup
	cp $filename $backup
fi

ersetzen() {
	nummer=`cat $filename| grep -ni $tag|cut -d ':' -f1`
	nummer=`expr $nummer - $davor`
	weiter=`expr $nummer + $anzahl`
	gesamt=`wc -l $filename|cut -d' ' -f1`
	cat $filename | sed -n "1,$nummer p" > $tmpfilename
	echo -n $einsetzen >> $tmpfilename
	cat $filename| sed -n "$weiter,$gesamt p" >> $tmpfilename
	rm $filename
	mv $tmpfilename $filename
}


loeschen() {
	cat $filename | grep -v "$tag" > $tmpfilename
	rm $filename
	mv $tmpfilename $filename
}

# echo debug  Als erstes den Google Analytics Block entfernen.
start=1
tag=googleanaly
anzahl=10
davor=2
einsetzen=""
ersetzen

# echo debug Jetzt das Video 1 einbauen
tag=Video1
anzahl=4
davor=2
einsetzen='<iframe class="youtube-player" type="text/html" width="640" height="385" src="http://www.youtube.com/embed/nAS0phx1g_Q" frameborder="0" allowfullscreen="1">
</iframe>'
ersetzen

# echo debug Jetzt das Video 2 einbauen
tag=Video2
anzahl=4
davor=2
einsetzen='<iframe class="youtube-player" type="text/html" width="550" height="430" src="http://www.youtube.com/embed/Om-LQ_Dbric" frameborder="0" allowfullscreen="1">
</iframe>'
ersetzen



mv $filename $tmpfilename
# Jetzt die Links anpassen
cat $tmpfilename | \
	sed -f sed-command-files/control-youtube.sed | \
	sed -f sed-command-files/remove-comments.sed | \
	sed -f sed-command-files/set-author.sed | \
	sed -f sed-command-files/relocate-default-reset.sed | \
	sed -f sed-command-files/relocate-default.sed | \
	sed -f sed-command-files/remove-overview.sed | \
	sed -f sed-command-files/remove-absolute-path.sed | \
	sed -f sed-command-files/anwenderbericht.sed | \
	sed -f sed-command-files/navigation-hint.sed | \
	sed -f sed-command-files/mikogo_en.sed | \
	sed -f sed-command-files/remove-google-analytics.sed |\
	sed "s/Deck Title/$Title/" | \
	sed "s/\"description\" content=\"TODO\"/\"description\" content=\"$Description\"/" | \
	sed "s/<img src=\".\/$page_files\/sl400x420.png\">/<a href=\".\/$filename#\/step-5\"> <img src=\".\/$page_files\/sl400x420.png\"><\/a>/g" | \
	sed "s/<img src=\".\/$page_files\/flag_de.png\">/  <a href=\".\/home.htm\">       <img src=\".\/$page_files\/flag_de.png\"><\/a>/g" | \
	sed "s@./home_files/aw.htm@http://www.seculution.de/versions/aw.txt@" | \
	sed "s@./home_files/agent.htm@http://www.seculution.de/versions/agent.txt@" | \
	sed "s@./home_files/server.htm@http://www.seculution.de/versions/server.txt@" | \
	sed "s@./home_files/uninstaller.htm@http://www.seculution.de/versions/uninstaller.txt@" | \
	sed "s@<div id=\"overview\" class=\"step future\" .*<\/div>@@" | \
	sed "s/http:\/\/www.4ss.de\/relative//g" | \
	sed "s/http:\/\/www.4ss.de\/$filename//g" | \
	sed "s/http:\/\/www.4ss.de/./" | \
	sed "s/http:\/\/www.seculution.de/./" | \
	sed "s/<img src=\".\/$page_files\/right.png\">/<a href=\"javascript:impress().next();\"><img src=\".\/$page_files\/right.png\"><\/a>/" | \
	sed "s/$page_files/support_files/g" | \
	cat > $filename

echo "<!-- processed -->" >> $filename

rm $tmpfilename

# Strut.io web bugs löschen
tag=strut.io
loeschen

exit 0








# Hier kommen Beispiele, die schon mal funktioniert haben, aber im Moment nicht wichtig sind

	sed 's/<font color="#000000" face="League Gothic">Live Support erhalten</font>/<!-- Mikogo Session Login Start -->\n<!-- <form method="POST" action="http:\/\/go.mikogo.com" style="display: inline;"> -->\n <form method="POST" action="http:\/\/go.mikogo.com" >\n <input type="hidden" name="sl" id="sl" value="de">\n <input type="hidden" name="css" id="css" value="">\n <input type="hidden" name="sid" id="sid" value="975-218-294">\n <input type="hidden" name="sn" id="sn" value="i">\n <input type="submit" value="Live Demo beitreten" id="btnSubmit" name="btnSubmit">\n <input type="hidden"id="cm" name="cm" value="2" checked="checked">\n <\/form>\n <form method="POST" action="http:\/\/go.mikogo.com" >\n <input type="hidden" name="sl" id="sl" value="de">\n <input type="hidden" name="css" id="css" value="">\n <input type="hidden" name="sid" id="sid" value="134-791-826">\n <input type="hidden" name="sn" id="sn" value="s">\n <input type="submit" value="Support erhalten" id="btnSubmit" name="btnSubmit">\n <input type="hidden"id="cm" name="cm" value="1" checked="checked">\n <\/form>\n <!-- Mikogo Session Login End -->/' | \
	sed 's/<img src=".\/index2_files\/sl400x420.png">/<a href="http:\/\/www.4ss.de\/$filename#\/step-3"> <img src=".\/index2_files\/sl400x420.png"><\/a>/g' | \
	sed 's/http:\/\/www.4ss.de\/$filename//g' | \
	cat > $filename

	# sed 's/<img src=".\/index2_files\/sl400x420.png">/<img src=".\/index2_files\/sl400x420.png">\n<a href="http:\/\/www.4ss.de\/$filename#\/step-3" class="img-link">/g' | \
